﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;

namespace ConsoleApp2
{
    class Program
    {

        [DllImport("kernel32")]
        private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);

        [DllImport("kernel32")]
        private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);

        

        

        static void Main(string[] args)
        {
            StringBuilder temp = new StringBuilder();

            //这个MYQQ是个块  ID是标签  798033502是值，一个块下可以有多个标签
            WritePrivateProfileString("MyQQ", "ID", "798033502", @"d:\QQ.ini");
            WritePrivateProfileString("MyQQ", "PWD", "**********", @"d:\QQ.ini");
            
            GetPrivateProfileString("MyQQ", "ID", "账号错误", temp, 255, @"d:\QQ.ini");

            string ID = temp.ToString();

            GetPrivateProfileString("MyQQ", "PWD", "账号错误", temp, 255, @"d:\QQ.ini");

            string PWD = temp.ToString();
            Console.WriteLine(ID);
            Console.WriteLine(PWD);
            Console.ReadLine();
            //HotelSystemORM.Unitl.IniFiles ini = new HotelSystemORM.Unitl.IniFiles(Application.StartupPath + @"\MyConfig.INI");
        }
    }
}
